<template>
  <div class="user-box">
    <el-select
      collapse-tags
      @change="searchState"
      v-model="stateParams"
      multiple
      :placeholder="$t('common.placeholder.selectWorkStatus')"
      style="width: 49%"
    >
      <el-option
        v-for="(color, state) in states"
        :label="state"
        :key="state"
        :value="state"
      >
        <span
          class="user-color-icon"
          :style="{ backgroundColor: color }"
        ></span>
        <span>{{ state }}</span>
      </el-option>
    </el-select>
    <el-select
      collapse-tags
      @change="searchState"
      v-model="labelIdsParams"
      multiple
      :placeholder="$t('common.placeholder.selectTag')"
      style="width: 49%"
    >
      <el-option
        v-for="item in tagList"
        :label="item.tagName"
        :value="item.id"
        :key="item.id"
      >
        <span>{{ item.tagName }}</span>
      </el-option>
    </el-select>
  </div>
</template>

<script>
// api
import { getBaseLabelList } from '@src/api/DepartmentApi';

export default {
  name: 'screening-user',
  props: {
    states: {
      type: Object,
      required: true,
      default: () => {}
    },
  },
  data() {
    return {
      stateColor: {}, //用户工作状态颜色
      isSeeAllOrg: false /** 是否 只可见本团队成员 */,
      tagList: [], // 标签数据

      stateParams: [],
      labelIdsParams: [],
    };
  },
  mounted(){
    this.getBaseLabelList();
  },
  methods:{
    // 获取标签数据
    getBaseLabelList(){
      getBaseLabelList().then(res=>{
        const { status,data,message } = res;
        if(status !== 0) return;

        this.tagList = data;
      })
    },
    // 变化
    searchState(){
      this.$emit('tagsChange',{ 
        tags: this.stateParams,
        label: this.labelIdsParams
      })
    }
  }
};
</script>

<style lang="scss" scoped>
.user-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  max-height: 50px;
  overflow: auto;
}
.user-state-item {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
}
.user-color-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 8px;
  background-color: #999;
}
::v-deep .el-select__tags {
  max-height: 32px;
  overflow: auto;
}
</style>